package com.example.demospringmybatisplus.service;

import java.util.Objects;

/**
 * SecureInvokeHolder管理线程局部变量 INVOKE_THREAD_LOCAL
 *
 * @author hauhua
 * @DATE 2025/1/21
 */
public class SecureInvokeHolder {
    private static final ThreadLocal<Boolean> INVOKE_THREAD_LOCAL = new ThreadLocal<>();

    public static boolean isInvoking() {
        return Objects.nonNull(INVOKE_THREAD_LOCAL.get());
    }

    public static void setInvoking() {
        INVOKE_THREAD_LOCAL.set(Boolean.TRUE);
    }

    public static void invoked() {
        INVOKE_THREAD_LOCAL.remove();
    }
}
